/***************************************************************************
 *   Copyright (C) 2009 by Jason Pullara                                   *
 *   lordkat@gmail.com                                                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include "common.h"

using namespace std;

class cNetwork;

class cClient {
	public:
		cClient();
		cClient(TCPsocket clientSocket, IPaddress clientAddress, cNetwork *pNetwork);
		~cClient();
		TCPsocket getTCPSocket();
		IPaddress getIPAddress();
		cClientState getClientState();

		void setClientState(cClientState clientState);
		void setClientType(cClientType clientType);
		void sendData(string sBuffer);

		string queueGet();

		cCharacter m_characterData;
		list<string> m_lRecvQueue;

	protected:
		static int recvThread(void *vData);
	private:
		TCPsocket m_tcpSocket;
		IPaddress m_ipAddress;
		cClientState m_clientState;
		cClientType m_clientType;
		SDL_Thread *m_threadRecv;
		SDL_sem *m_semClientLock;
		cNetwork *m_pNetwork;
		char m_cBuffer[10240];
		int m_iBufferLen;
		bool m_bIsNPC;
};
